package com.sywb.chuangyebao.view.video;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;

import com.sywb.chuangyebao.R;
import com.sywb.chuangyebao.adapter.SuperRecyclerAdapter;
import com.sywb.chuangyebao.bean.VideoData;
import com.sywb.chuangyebao.bean.VideoInfo;
import com.sywb.chuangyebao.contract.VideoContract;

public class VideoAdapter extends SuperRecyclerAdapter<VideoData, VideoHolder> {

    private Activity activity;
    private int videoUid;

    private OnVideoHolderCallback onVideoHolderCallback;

    public VideoAdapter(Activity activity, int videoUid) {
        super(activity, R.layout.item_video);
        this.activity = activity;
        this.videoUid = videoUid;
    }

    @Override
    protected VideoHolder onCreateViewHolder(ViewGroup parent, android.view.View itemView) {
        VideoHolder viewHolder = new VideoHolder(activity, itemView, mOnItemClickListener, mOnItemLongClickListener);
        viewHolder.setVideoUid(videoUid);
        viewHolder.setVideoHolderCallback(onVideoHolderCallback);
        viewHolder.getViewHolderHelper().setOnItemChildClickListener(mOnItemChildClickListener);
        viewHolder.getViewHolderHelper().setOnItemChildLongClickListener(mOnItemChildLongClickListener);
        return viewHolder;
    }

    @Override
    protected int getDefItemViewType(int position) {
        if (position >= getDataCount()) {
            return 0x00000333;
        }
        return super.getDefItemViewType(position);
    }

    @Override
    protected void setItemData(VideoHolder viewHolder, int position, VideoData model) {
        viewHolder.setItemData(position, model);
    }

    public void setVideoHolderCallback(OnVideoHolderCallback onVideoHolderCallback) {
        this.onVideoHolderCallback = onVideoHolderCallback;
    }
}
